package com.wtwd.campus.receiver;

import com.wtwd.campus.entity.MqGeneralValueResult;
import com.wtwd.campus.service.IRMFeignClientService;
import com.wtwd.campus.service.InjectFeignService;
import org.springframework.beans.factory.annotation.Autowired;

public class ResetMCardReceiver implements Receiver {
    @Autowired
    private IRMFeignClientService irmFeignClientService;

    @Override
    public String parseMessage(String data) {
        //*XX,YYYYYYYYYYYYYYY,SETM1,HHMMSS,M1,DDMMYY,tracker_status#
        String[] split = data.split(",");
        String imei = split[1];
        String messageType = split[2];
        String commandNumber = split[3];
        String mCard = split[4];//改变后的m1卡号
        String date = split[5];//日月年
        String deviceStatus = split[6];
        MqGeneralValueResult mqGeneralValueResult = new MqGeneralValueResult();
        mqGeneralValueResult.setDeviceStatus(deviceStatus);
        mqGeneralValueResult.setDeviceDate(date);
        mqGeneralValueResult.setValue(mCard);
        mqGeneralValueResult.setImei(imei);
        mqGeneralValueResult.setDeviceTime(commandNumber);
        mqGeneralValueResult.setCommandNumber(commandNumber);
        InjectFeignService.getIrmFeignClientService().resetM1Card(mqGeneralValueResult);
        return imei;
    }
}
